﻿using System;
using System.Linq.Expressions;
using BrettM.Data;

namespace BrettM.Linq
{
    public static class Extensions
    {
        public static Expression<Func<TEntity, bool>> AsAt<TEntity>(DateTime dateTime)
            where TEntity : IValidFromTo
        {            
            return e =>  (e.ValidFrom <= dateTime) &&
               (e.ValidTo == null || e.ValidTo >= dateTime);
        }
    }
}
